﻿using Store.Manager.ERP.Domain.Entities;
using Store.Manager.ERP.Domain.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Store.Manager.ERP.Infrastructure
{
    public class ProductRepository : IProductRepository
    {
        private Repository<Product> _repository;
        public ProductRepository(Repository<Product> repository)
        {
            _repository = repository;
        }

        public async Task AddAsync(Product product)
        {
            await _repository.InsertAsync(product);
        }

        public async Task AddRangeAsync(List<Product> products)
        {
            await _repository.InsertRangeAsync(products);
        }

        public async Task UpdateAsync(Product product)
        {
            await _repository.UpdateAsync(product);
        }

        public async Task DeleteAsync(string code)
        {
            await _repository.DeleteByIdAsync(code);
        }

        public async Task<Product> GetByCodeAsync(string code)
        {
            return await _repository.GetByIdAsync(code);
        }

        public async Task<List<Product>> GetAllAsync()
        {
            return await _repository.GetListAsync();
        }
    }
}
